home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #43 (Apr 89) / XCMDSource Code / ADSPTalk.p < prev   
Text File  |  1989-02-07  |  2KB  |  110 lines

  1. (****************************)
  2. (*    file:         ADSPTalk.p        *)
  3. (*                                                     *)
  4. (* Send information to an     *)
  5. (* established connection.  *)
  6. (* The connection must be        *)
  7. (* been established via the    *)
  8. (* ADSPCALL xcmd.                        *)
  9. (*                                                    *)
  10. (* In:                                            *)
  11. (* params[1] =    entity name    *)
  12. (* of the remote end.                *)
  13. (*                                                    *)
  14. (* ------------------------    *)
  15. (* By:        Donald Koscheka        *)
  16. (* Date:    2-Mar-89                    *)
  17. (*        All Rights Reserved        *)
  18. (*                                                    *)
  19. (* ------------------------    *)
  20. (****************************)
  21.  
  22. (*****************************
  23.                             Build Sequence
  24.  
  25. pascal -o ADSPTalk.p.o ADSPTalk.p
  26. link -m ENTRYPOINT  -rt XCMD=1305 -sn Main=ADSPTalk∂
  27.     ADSPTalk.p.o∂
  28.     "{libraries}"Interface.o ∂
  29.     -o YourStackNameHere
  30.          
  31. *****************************)
  32.  
  33.  
  34. {$R-}
  35. {$S ADSPTalk}
  36. UNIT DummyUnit;
  37.  
  38. (****************************)
  39.                     INTERFACE 
  40. (****************************)
  41.  
  42.  
  43. Uses    MemTypes, QuickDraw, OSIntf,
  44.             ToolIntf, PackIntf, HyperXCmd,
  45.             AppleTalk, ADSP, adspxcmd;
  46.  
  47.  
  48. Procedure EntryPoint( paramPtr : XCmdPtr );
  49.  
  50.  
  51.  
  52. (****************************)
  53.             IMPLEMENTATION
  54. (****************************)
  55. TYPE Str31 = String[31];
  56.  
  57.  
  58. PROCEDURE ADSPTalk( paramPtr: XCmdPtr ); FORWARD;
  59.  
  60. Procedure EntryPoint( paramPtr : XCmdPtr );
  61.     Begin
  62.         ADSPTalk( paramPtr );
  63.     End;
  64.     
  65.     
  66. Procedure ADSPTalk( paramPtr : XCmdPtr );
  67. VAR
  68.     adsp        : ADSPPtr;
  69.     error        : OSErr;
  70.     eAddr        : AddrBlock;
  71.     cb            : cbPtr;
  72.     
  73. {$I XCmdGlue.inc }
  74. {$I XCMDADSP.inc }    
  75.  
  76. BEGIN
  77.     error := noErr;
  78.         adsp := ADSPPtr(RetrieveData( 'GLOBALDSPDATA' ));
  79.     IF    (adsp <> NIL)    
  80.     AND    (paramPtr^.params[1] <> NIL)
  81.     AND    (paramPtr^.params[2] <> NIL) THEN
  82.     BEGIN
  83.         adsp^.checkPoint := RECEIVING;
  84.         {*** (1) Get the entity's address             ***}
  85.         HLock( paramPtr^.params[1] );
  86.  
  87.         eAddr := NBPGetAddress( paramPtr^.params[1]^ );
  88.         cb := adsp^.ends;
  89.  
  90.      {*** (2) Find entity in connection list***}        
  91.         IF LongInt( eAddr ) <> 0 THEN
  92.             WHILE cb <> NIL DO
  93.                 IF (LongInt(cb^.adr)=LongInt(eAddr)) 
  94.                 AND (cb^.ccb.state=sOpen) THEN    
  95.                 BEGIN
  96.                     error := DSPTalk(cb, paramPtr^.params[2] );
  97.                     cb := NIL;
  98.                 END
  99.                 ELSE
  100.                     cb := cb^.next;
  101.                         
  102.         adsp^.checkPoint := CLOSE_OK;
  103.         HUnlock( Handle(paramPtr^.params[1]) );
  104.     END;
  105.     paramPtr^.returnValue := PasToZero( NumToStr( LongInt(error) ) );
  106. END;
  107.  
  108.  
  109. end.
  110.